package com.jh3502.vivo.function.tododetail.travel;

/**
 * @author harisucici
 * @date 2017/6/19
 */

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jh3502.vivo.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class TodoDetailChangeTasAdapter extends RecyclerView.Adapter<TodoDetailChangeTasAdapter.ViewHolder> {


    private Context mContext;
    private List<TodoDetailChangeBean.TasBean> listItems;
    private View convertView;

    public TodoDetailChangeTasAdapter(Context context, List<TodoDetailChangeBean.TasBean> datas) {
        this.listItems = datas;
        this.mContext = context;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
        convertView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_todo_detail_travel_change_tas, viewGroup, false);
        ViewHolder vh = new ViewHolder(convertView);
        return vh;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int position) {
        viewHolder.itemView.setTag(position);
        viewHolder.name.setText(listItems.get(position).getUserName());
        viewHolder.date.setText(listItems.get(position).getCreatedate());
        int state = listItems.get(position).getState();
        if (state == 0) {
            viewHolder.result.setText("待审批");
        } else if (state == 1) {
            viewHolder.result.setText("同意");
        } else if (state == 2) {
            viewHolder.result.setText("不同意");
        }

    }


    @Override
    public int getItemCount() {
        return listItems.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.name)
        TextView name;
        @BindView(R.id.date)
        TextView date;
        @BindView(R.id.result)
        TextView result;

        public ViewHolder(@NonNull View view) {

            super(view);
            ButterKnife.bind(this, view);
        }
    }


}